﻿$(document).ready(function () {

});

function OnCustomCommand(s, e) {
    switch (e.commandName) {
        case "AddTitle":
            UpdateImageTitle(GetSelectedElement());
            break;
        case "ChangeTitle":
            UpdateImageTitle(GetSelectedElement());
            break;
        case "RemoveTitle":
            RemoveImageTitle(GetSelectedElement());
            break;
    }
}

function OnContextMenuShowing(s, e) {
    var contextMenu = s.GetContextMenu();
    var selectedElement = GetSelectedElement();
    var isImageSelected = IsImageElement(selectedElement);

    SetContextMenuItemVisible(contextMenu, "AddTitle", isImageSelected && !selectedElement.title);
    SetContextMenuItemVisible(contextMenu, "ChangeTitle", isImageSelected && selectedElement.title);
    SetContextMenuItemVisible(contextMenu, "RemoveTitle", isImageSelected && selectedElement.title);
}

function DeleteImage(id) {
    $('#' + id).hide();
    $('#hidden_' + id).val(true);
}